clear 

** read in .dta file **

use "${clean}/who_counts_analysis.dta", clear


** Coefficent Plots, Robustness Regressions, 1945-1955 **

drop if YOB > 1955

xi: reghdfe MOB did_ANY Arabic Female *_itTREATED *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW1_any
estimates store m_MOB_did_BW1_any

xi: reghdfe Schooling did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW1_any

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW1_any

xi: reghdfe French_Lit did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW1_any

preserve

drop if geo2_ma==504009001

** Main specification wout Casablanca ** 

xi: reghdfe MOB did_ANY Arabic Female *_itTREATED *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW1_casa

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW1_casa

xi: reghdfe French_Lit did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW1_casa

xi: reghdfe Schooling did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW1_casa

restore

preserve 

drop if ma1994a_durres!=97

*** Main specification

xi: reghdfe MOB did_ANY Arabic Female *_itTREATED *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW1_migrant

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW1_migrant

xi: reghdfe French_Lit did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW1_migrant

xi: reghdfe Schooling did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW1_migrant

restore

** Output Plots ** 

coefplot (m_MOB_did_BW1_any, label(1945-1955)) (m_MOB_did_BW1_casa, label(1945-1955, No Casablanca)) (m_MOB_did_BW1_migrant, label(1945-1955, No Migrants)), keep(did_ANY) vertical yline(0) title("Registration") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/MOB_BW.gph", replace

coefplot(m_School_did_BW1_any, label(1945-1955)) (m_School_did_BW1_casa, label(1945-1955, No Casablanca)) (m_School_did_BW1_migrant, label(1945-1955, No Migrants)), keep(did_edu_ANY) vertical yline(0) title("Formal Schooling") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/Schooling_BW.gph", replace

coefplot(m_YRS_did_BW1_any, label(1945-1955)) (m_YRS_did_BW1_casa, label(1945-1955, No Casablanca)) (m_YRS_did_BW1_migrant, label(1945-1955, No Migrants)), keep(did_edu_ANY) vertical yline(0) title("Formal Schooling, Years") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/YRS_BW.gph", replace

coefplot(m_LIT_did_BW1_any, label(1945-1955)) (m_LIT_did_BW1_casa, label(1945-1955, No Casablanca)) (m_LIT_did_BW1_migrant, label(1945-1955, No Migrants)), keep(did_edu_ANY) vertical yline(0) title("Literacy, French and Arabic") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/LIT_BW.gph", replace

grc1leg  "${output}/graphs/MOB_BW.gph" "${output}/graphs/Schooling_BW.gph" "${output}/graphs/YRS_BW.gph" "${output}/graphs/LIT_BW.gph",legendfrom("${output}/graphs/Schooling_BW.gph")
graph save Graph "${output}/graphs/DiD_BW_ALL.gph", replace
graph export "${output}/graphs/Figure8A.png", replace
